import com.wcarmon.life.model.LifeModelLocator;
import com.wcarmon.life.event.ShowOrganizeZoomEvent;
import com.wcarmon.life.vo.DoScreenVO;
import mx.controls.Alert;
import mx.utils.ObjectUtil;
import mx.utils.StringUtil;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;


include "../../../includes/loggerSnippet.as";

[Bindable]
private var model : LifeModelLocator = LifeModelLocator.getInstance();	        	

[Bindable]
private var currentList : Array;
private var currentListLabel : String;




public function doInit() : void{
	log.debug('initalizing do screen');
	
	log.warn('GIVON: this should be pulling the correct context from model.currentDoScreen ...' );
	currentList = model.currentDoScreen.all;
	makeContextMenu();
}

private function makeContextMenu() : void{
	log.debug('creating context menu for do screen');
	var m : ContextMenu = new ContextMenu();
	m.hideBuiltInItems();
	var actions : Array = new Array();
	
	var zoom : ContextMenuItem = new ContextMenuItem("Zoom on Next Action");
	zoom.addEventListener( "menuItemSelect", handleZoom );
	//...
	actions.push( zoom );
	//actions.push( ? );
	log.warn('GIVON: finish implementing "makeContextMenu" for do screen');
	
	m.customItems = actions;
	this.contextMenu = m;
}

private function handleZoom(e: ContextMenuEvent) : void {
	Alert.show( "contextmenu click (event): " + e );
	log.info("context menu event in do screen: " + e);
}

private function doZoom( id : uint ) : void {
	( new ShowOrganizeZoomEvent(id) ).dispatch();
}

private function doEdit( id : uint ) : void {
	log.warn("GIVON: implement 'doEdit'");
	Alert.show('implement edit...');
}

private function doComplete( id : uint ) : void {
	log.warn("GIVON: implement 'doComplete'");
	Alert.show('implement Complete...');
}

private function doReject( id : uint ) : void {
	log.warn("GIVON: implement 'doReject'");
	Alert.show('implement Reject...');
}


private function getDataArray( selected : Object, d : DoScreenVO ) : Array {
	log.debug('getting the data array for do screen');
	if( currentListLabel != selected.data ){
		currentListLabel = selected.data;
 		currentList = d[ selected.data ];
	}
	return currentList;
}

private function doPrint() : void{
	log.warn('GIVON: implement printing on Do Screen');
	Alert.show("implemenet printing");
}
         	
